import { CREATURE_TYPE } from '../options/creature-type';
import { Flag } from '@keira/shared/constants';

export const SPELL_DBC_CREATURE_TYPE_FLAGS: Flag[] = CREATURE_TYPE.slice(1, CREATURE_TYPE.length).map((option) => ({
  bit: (option.value as number) - 1,
  name: option.name,
}));

export const SPELL_DBC_FACING_FRONT_FLAG: Flag[] = [{ bit: 0, name: 'FacingFront' }];

export const SPELL_DBC_INTERRUPT_FLAGS: Flag[] = [
  { bit: 0, name: 'On movement' },
  { bit: 1, name: 'On knockback' },
  { bit: 2, name: 'On interrupt casting' },
  { bit: 3, name: 'On interrupt school' },
  { bit: 4, name: 'On damage taken' },
  { bit: 5, name: 'On interrupt all' },
];

export const SPELL_DBC_AURA_INTERRUPT_FLAGS: Flag[] = [
  { bit: 0, name: 'On hit by spell' },
  { bit: 1, name: 'On take damage' },
  { bit: 2, name: 'On casting' },
  { bit: 3, name: 'On moving' },
  { bit: 4, name: 'On turning' },
  { bit: 5, name: 'On jumping' },
  { bit: 6, name: 'Not mounted' },
  { bit: 7, name: 'Not above water' },
  { bit: 8, name: 'Not underwater' },
  { bit: 9, name: 'Not Sheathed' },
  { bit: 10, name: 'On talk' },
  { bit: 11, name: 'On use' },
  { bit: 12, name: 'On melee attack' },
  { bit: 13, name: 'On spell attack' },
  { bit: 14, name: 'Unknown' },
  { bit: 15, name: 'On transform' },
  { bit: 16, name: 'Unknown' },
  { bit: 17, name: 'On mount' },
  { bit: 18, name: 'Not seated' },
  { bit: 19, name: 'On change map' },
  { bit: 20, name: 'Immune or lost selection' },
  { bit: 21, name: 'Unknown' },
  { bit: 22, name: 'On teleport' },
  { bit: 23, name: 'On enter PvP combat' },
  { bit: 24, name: 'On direct damage' },
  { bit: 25, name: 'Landing' },
];

export const SPELL_DBC_STANCES_FLAGS: Flag[] = [
  { bit: 0, name: 'Cat' },
  { bit: 1, name: 'Tree' },
  { bit: 2, name: 'Travel' },
  { bit: 3, name: 'Aqua' },
  { bit: 4, name: 'Bear' },
  { bit: 5, name: 'Ambient' },
  { bit: 6, name: 'Ghoul' },
  { bit: 7, name: 'Dire Bear' },
  { bit: 8, name: 'Steves Ghoul' },
  { bit: 9, name: 'Tharonja Skeleton' },
  { bit: 10, name: 'Test of Strength' },
  { bit: 11, name: 'BLB Player' },
  { bit: 12, name: 'Shadow Dance' },
  { bit: 13, name: 'Creature Bear' },
  { bit: 14, name: 'Creature Cat' },
  { bit: 15, name: 'Ghost Wolf' },
  { bit: 16, name: 'Battle Stance' },
  { bit: 17, name: 'Defensive Stance' },
  { bit: 18, name: 'Berserker Stance' },
  { bit: 19, name: 'Test' },
  { bit: 20, name: 'Zombie' },
  { bit: 21, name: 'Metamorphosis' },
  { bit: 22, name: 'Undead' },
  { bit: 23, name: 'Master Angler' },
  { bit: 24, name: 'Flight (Epic)' },
  { bit: 25, name: 'Shadow' },
  { bit: 26, name: 'Flight (Normal)' },
  { bit: 27, name: 'Stealth' },
  { bit: 28, name: 'Moonkin' },
  { bit: 29, name: 'Spirit of Redemption' },
];

export const SPELL_DBC_CHANNEL_INTERRUPT_FLAGS: Flag[] = [
  { bit: 0, name: 'On 1' },
  { bit: 1, name: 'On 2' },
  { bit: 2, name: 'On 3' },
  { bit: 3, name: 'On 4' },
  { bit: 4, name: 'On 5' },
  { bit: 5, name: 'On 6' },
  { bit: 6, name: 'On 7' },
  { bit: 7, name: 'On 8' },
  { bit: 8, name: 'On 9' },
  { bit: 9, name: 'On 10' },
  { bit: 10, name: 'On 11' },
  { bit: 11, name: 'On 12' },
  { bit: 12, name: 'On 13' },
  { bit: 13, name: 'On 14' },
  { bit: 14, name: 'On 15' },
  { bit: 15, name: 'On 16' },
  { bit: 16, name: 'On 17' },
  { bit: 17, name: 'On 18' },
];

export const SPELL_DBC_ATTRIBUTES_FLAGS: Flag[][] = [];

SPELL_DBC_ATTRIBUTES_FLAGS[''] = [
  { bit: 0, name: 'Proc failure burns charges' },
  { bit: 1, name: 'Uses ranged slot' },
  { bit: 2, name: 'On next swing (damage irrelevant)' },
  { bit: 3, name: 'Do not log immune misses' },
  { bit: 4, name: 'Is ability' },
  { bit: 5, name: 'Is trade skill' },
  { bit: 6, name: 'Passive' },
  { bit: 7, name: 'Do not display (spellbook, aura icon, combat log)' },
  { bit: 8, name: 'Do not log' },
  { bit: 9, name: 'Held item only' },
  { bit: 10, name: 'On next swing' },
  { bit: 11, name: 'Wearer casts proc trigger' },
  { bit: 12, name: 'Server only' },
  { bit: 13, name: 'Allow item spell in PvP' },
  { bit: 14, name: 'Indoors only' },
  { bit: 15, name: 'Outdoors only' },
  { bit: 16, name: 'Not shapeshifted' },
  { bit: 17, name: 'Only stealthed' },
  { bit: 18, name: 'Do not Sheath' },
  { bit: 19, name: 'Spell damage scales with level' },
  { bit: 20, name: 'Cancels auto attack combat' },
  { bit: 21, name: 'Impossible to dodge, parry or block' },
  { bit: 22, name: 'Track target while casting' },
  { bit: 23, name: 'Castable while dead' },
  { bit: 24, name: 'Castable while mounted' },
  { bit: 25, name: 'Start cooldown after aura fades' },
  { bit: 26, name: 'Negative effect / Aura is debuff' },
  { bit: 27, name: 'Castable while sitting' },
  { bit: 28, name: 'Cannot be used in combat' },
  { bit: 29, name: 'Unaffected by invulnerability' },
  { bit: 30, name: 'Breakable by damage' },
  { bit: 31, name: 'Aura cannot be cancelled' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex'] = [
  { bit: 0, name: 'Dismiss pet first' },
  { bit: 1, name: 'Drains all power' },
  { bit: 2, name: 'Is channelled' },
  { bit: 3, name: 'Cannot be redirected' },
  { bit: 4, name: 'No skill increase' },
  { bit: 5, name: 'Allow while stealthed' },
  { bit: 6, name: 'Is self channeled' },
  { bit: 7, name: 'Cannot be reflected' },
  { bit: 8, name: 'Cannot target in combat' },
  { bit: 9, name: 'Initiates combat (Enables auto attack)' },
  { bit: 10, name: 'Generates no threat' },
  { bit: 11, name: 'Aura unique' },
  { bit: 12, name: 'Failure breaks stealth' },
  { bit: 13, name: 'Far sight' },
  { bit: 14, name: 'Track target while channelling' },
  { bit: 15, name: 'Remove auras on immunity' },
  { bit: 16, name: 'Immunity to hostile and friendly effects' },
  { bit: 17, name: 'No auto-cast (AI only)' },
  { bit: 18, name: 'Prevents animation' },
  { bit: 19, name: 'Cannot target self' },
  { bit: 20, name: 'Finishing move - damage' },
  { bit: 21, name: 'Threat only on miss' },
  { bit: 22, name: 'Finishing move - duration' },
  { bit: 23, name: 'Ignore owners death' },
  { bit: 24, name: 'Speacial skillup' },
  { bit: 25, name: 'Aura stays after combat' },
  { bit: 26, name: 'Require all targets' },
  { bit: 27, name: 'Discount power on miss' },
  { bit: 28, name: 'Hidden in aura bar' },
  { bit: 29, name: 'Name in channel bar' },
  { bit: 30, name: 'Enable spell when dodged / Combo on block' },
  { bit: 31, name: 'Cast when learned' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex2'] = [
  { bit: 0, name: 'Can target dead unit or corpse' },
  { bit: 1, name: 'No shapeshift UI' },
  { bit: 2, name: 'Ignore line of sight' },
  { bit: 3, name: 'Allow low level buff' },
  { bit: 4, name: 'Display in stance bar / use shapeshift bar' },
  { bit: 5, name: 'Auto repeat' },
  { bit: 6, name: 'Requires untapped target' },
  { bit: 7, name: 'Do not report spell failure' },
  { bit: 8, name: 'Include in advanced combat log' },
  { bit: 9, name: 'Always cast as unit' },
  { bit: 10, name: 'Special taming flag' },
  { bit: 11, name: 'No target per-second costs' },
  { bit: 12, name: 'Chain from caster' },
  { bit: 13, name: 'Preserve enchant in Arena' },
  { bit: 14, name: 'Allow while invisible' },
  { bit: 15, name: 'Do not consume if gained during cast' },
  { bit: 16, name: 'No active pets' },
  { bit: 17, name: 'Do not reset combat timers' },
  { bit: 18, name: 'Requires dead pet / No jump while cast pending' },
  { bit: 19, name: 'Does not need shapeshift' },
  { bit: 20, name: 'Inititate combat post cast (enable auto attack)' },
  { bit: 21, name: 'Fail on all targets immune' },
  { bit: 22, name: 'No initial threat' },
  { bit: 23, name: 'Proc cooldown on failure' },
  { bit: 24, name: 'Item cast with owner skill' },
  { bit: 25, name: 'Do no block mana regeneration' },
  { bit: 26, name: 'No school immunities' },
  { bit: 27, name: 'Ignore weapon skill' },
  { bit: 28, name: 'Not an action' },
  { bit: 29, name: 'Cannot crit' },
  { bit: 30, name: 'Active threat' },
  { bit: 31, name: 'Retain item cast' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex3'] = [
  { bit: 0, name: 'Enables PvP' },
  { bit: 1, name: 'No proc equip requirement' },
  { bit: 2, name: 'No casting bar text' },
  { bit: 3, name: 'Blockable spell / Completely blocked' },
  { bit: 4, name: 'Ignore resurrection timer' },
  { bit: 5, name: 'No durability loss' },
  { bit: 6, name: 'No avoidance' },
  { bit: 7, name: 'Stack for different casters' },
  { bit: 8, name: 'Only target players' },
  { bit: 9, name: 'Not a proc' },
  { bit: 10, name: 'Requires main hand' },
  { bit: 11, name: 'Battleground only' },
  { bit: 12, name: 'Only target ghosts' },
  { bit: 13, name: 'Hide channel bar' },
  { bit: 14, name: 'Hide in raid filter' },
  { bit: 15, name: 'Normal ranged attack (auto shoot)' },
  { bit: 16, name: 'Suppress caster procs' },
  { bit: 17, name: 'Suppress target procs' },
  { bit: 18, name: 'Cannot miss' },
  { bit: 19, name: 'Disable procs / instant target procs' },
  { bit: 20, name: 'Persistent on death' },
  { bit: 21, name: 'Only proc outdoors' },
  { bit: 22, name: 'Casting cancels autorepeat ' },
  { bit: 23, name: 'No damage history' },
  { bit: 24, name: 'Requires off hand' },
  { bit: 25, name: 'Treat as periodic' },
  { bit: 26, name: 'Can proc from procs' },
  { bit: 27, name: 'Only proc on caster' },
  { bit: 28, name: 'Ignore caster and target restrictions' },
  { bit: 29, name: 'Ignore caster modifiers' },
  { bit: 30, name: 'Do not display range in tooltip' },
  { bit: 31, name: 'Not on AoE immune' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex4'] = [
  { bit: 0, name: 'Ignore all resistances' },
  { bit: 1, name: 'Proc only on caster' },
  { bit: 2, name: 'Continue to tick while offline' },
  { bit: 3, name: 'No helpful threat' },
  { bit: 4, name: 'No harmful threat' },
  { bit: 5, name: 'Allow client targeting' },
  { bit: 6, name: 'Cannot be stolen' },
  { bit: 7, name: 'Allow cast while casting / triggered' },
  { bit: 8, name: 'Fixed damage / ignore damage taken modifiers (e.g. block)' },
  { bit: 9, name: 'Activate from event / combat feedback when usable' },
  { bit: 10, name: 'Spell vs extended cost / weapon speed cost scale' },
  { bit: 11, name: 'No partial immunity' },
  { bit: 12, name: 'Aura is buff' },
  { bit: 13, name: 'Do not log caster' },
  { bit: 14, name: 'Damage does not break auras / reactive damage proc' },
  { bit: 15, name: 'Not in spellbook' },
  { bit: 16, name: 'Not usable in arena' },
  { bit: 17, name: 'Usable in arena' },
  { bit: 18, name: 'Bouncy chain missiles' },
  { bit: 19, name: 'Allow proc while sitting' },
  { bit: 20, name: 'Do not check selfcast power / aura never bounces' },
  { bit: 21, name: 'Allow entering arena' },
  { bit: 22, name: 'Proc suppress swing animation' },
  { bit: 23, name: 'Suppress weapon procs' },
  { bit: 24, name: 'Auto ranged combat' },
  { bit: 25, name: 'Pet scaling / owner power scaling' },
  { bit: 26, name: 'Can only be used in flying areas' },
  { bit: 27, name: 'Force displaying castbar' },
  { bit: 28, name: 'Ignore combat timer' },
  { bit: 29, name: 'Aura bounce fails spell' },
  { bit: 30, name: 'Obsolete' },
  { bit: 31, name: 'Use facing from spell' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex5'] = [
  { bit: 0, name: 'Allow Actions During Channel' },
  { bit: 1, name: 'No Reagent Cost With Aura' },
  { bit: 2, name: 'Remove Entering Arena' },
  { bit: 3, name: 'Allow While Stunned' },
  { bit: 4, name: 'Triggers Channeling' },
  { bit: 5, name: 'Single-Target Spell / Limit N' },
  { bit: 6, name: 'Ignore Area Effect PvP Check' },
  { bit: 7, name: 'Not On Player' },
  { bit: 8, name: 'Not On Player Controlled NPC' },
  { bit: 9, name: 'Start Periodic at Aura Apply / Extra Initial Period' },
  { bit: 10, name: 'Do Not Display Duration' },
  { bit: 11, name: 'Allow Target of Target as Target / Implied Targeting' },
  { bit: 12, name: 'Melee Chain Targeting (Cleave)' },
  { bit: 13, name: 'Spell Haste Affects Periodic (Duration)' },
  { bit: 14, name: 'Not Available While Charmed' },
  { bit: 15, name: 'Treat as Area Effect (Inflict on Multiple Targets)' },
  { bit: 16, name: 'Aura Affects Not Just Req. Equipped Item ' },
  { bit: 17, name: 'Allow While Fleeing (Feared)' },
  { bit: 18, name: 'Allow While Confused' },
  { bit: 19, name: 'AI Does not Face Target / Does not Turn during Casting' },
  { bit: 20, name: 'Do Not Attempt a Pet Resummon When Dismounting' },
  { bit: 21, name: 'Ignore Target Requirements' },
  { bit: 22, name: 'Not On Trivial' },
  { bit: 23, name: 'No Partial Resists' },
  { bit: 24, name: 'Ignore Caster Requirements' },
  { bit: 25, name: 'Always Line of Sight' },
  { bit: 26, name: 'Always AOE Line of Sight' },
  { bit: 27, name: 'No Caster Aura Icon' },
  { bit: 28, name: 'No Target Aura Icon' },
  { bit: 29, name: 'Aura Unique Per Caster' },
  { bit: 30, name: 'Always Show Ground Texture' },
  { bit: 31, name: 'Add Melee Hit Rating / AoE Taunt' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex6'] = [
  { bit: 0, name: 'No Cooldown On Tooltip' },
  { bit: 1, name: 'Do Not Reset Cooldown In Arena' },
  { bit: 2, name: 'Not an Attack / Ignore Caster Auras' },
  { bit: 3, name: 'Can Assist Immune PC / Assist Ignore Immune Flag' },
  { bit: 4, name: 'Ignore For Mod Time Rate' },
  { bit: 5, name: 'Do Not Consume Resources' },
  { bit: 6, name: 'Floating Combat Text On Cast' },
  { bit: 7, name: 'Aura Is Weapon Proc' },
  { bit: 8, name: 'Do Not Chain To Crowd-Controlled Targets' },
  { bit: 9, name: 'Allow On Charmed Targets' },
  { bit: 10, name: 'No Aura Log' },
  { bit: 11, name: 'Not In Raid Instances' },
  { bit: 12, name: 'Allow While Riding Vehicle' },
  { bit: 13, name: 'Can Target Invisible / Ignore Phase Shift' },
  { bit: 14, name: 'AI Primary Ranged Attack' },
  { bit: 15, name: 'No Pushback' },
  { bit: 16, name: 'No Jump Pathing' },
  { bit: 17, name: 'Allow Equip While Casting' },
  { bit: 18, name: 'Originate From Controller' },
  { bit: 19, name: 'Delay Combat Timer During Cast' },
  { bit: 20, name: 'Aura Icon Only For Caster (Limit 10)' },
  { bit: 21, name: 'Show Mechanic as Combat Text' },
  { bit: 22, name: 'Absorb Cannot Be Ignore' },
  { bit: 23, name: 'Taps immediately' },
  { bit: 24, name: 'Can Target Untargetable' },
  { bit: 25, name: 'Does not Reset Swing Timer if Instant' },
  { bit: 26, name: 'Vehicle Immunity Category' },
  { bit: 27, name: 'Ignore Healing Modifiers' },
  { bit: 28, name: 'Do Not Auto Select Target with Initiates Combat' },
  { bit: 29, name: 'Ignore Caster Damage Modifiers' },
  { bit: 30, name: 'Disable Tied Effect Points' },
  { bit: 31, name: 'No Category Cooldown Mods' },
];

SPELL_DBC_ATTRIBUTES_FLAGS['Ex7'] = [
  { bit: 0, name: 'Allow Spell Reflection / Feign Death' },
  { bit: 1, name: 'No Target Duration Mod' },
  { bit: 2, name: 'Disable Aura While Dead' },
  { bit: 3, name: 'Cheat Spell / Debug Spell' },
  { bit: 4, name: 'Treat as Raid Buff' },
  { bit: 5, name: 'Can Be Multi Cast (Totem)' },
  { bit: 6, name: 'Do not Cause Spell Pushback' },
  { bit: 7, name: 'Prepare for Vehicle Control End' },
  { bit: 8, name: 'Horde Only' },
  { bit: 9, name: 'Alliance Only' },
  { bit: 10, name: 'Dispel Removes Charges' },
  { bit: 11, name: 'Can Cause Interrupt (Interrupt only Non-Player)' },
  { bit: 12, name: 'Can Cause Silence' },
  { bit: 13, name: 'No UI Not Interruptible' },
  { bit: 14, name: 'Recast On Resummon (Raise Dead)' },
  { bit: 15, name: 'Reset Swing Timer at spell start' },
  { bit: 16, name: 'Only In Spellbook Until Learned (Restore Secondary Power)' },
  { bit: 17, name: 'Do Not Log PvP Kill' },
  { bit: 18, name: 'Attack on Charge to Unit' },
  { bit: 19, name: 'Report Spell failure to unit target (Zone Teleport)' },
  { bit: 20, name: 'No Client Fail While Stunned, Fleeing, Confused (Blink, Divine Shield, Ice Block)' },
  { bit: 21, name: 'Retain Cooldown Through Load' },
  { bit: 22, name: 'Ignores Cold Weather Flying Requirement' },
  { bit: 23, name: 'No Attack Dodge' },
  { bit: 24, name: 'No Attack Parry' },
  { bit: 25, name: 'No Attack Miss' },
  { bit: 26, name: 'Treat as NPC AoE' },
  { bit: 27, name: 'Bypass No Resurrect Aura' },
  { bit: 28, name: 'Do Not Count For PvP Scoreboard / Consolidated Raid Buff' },
  { bit: 29, name: 'Reflection Only Defends' },
  { bit: 30, name: 'Can Proc From Suppressed Target Procs' },
  { bit: 31, name: 'Always Cast Log / Client Indicator' },
];
